﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FCNS.KeepMoney.Data
{
    class DataFormatCSV : IDataFormat
    {
        public string Name
        {
            get { return "CSV 格式"; }
        }

        public string Extension
        {
            get { return "(*.csv)|*.csv"; }
        }

        public string ExampleUrl
        {
            get
            {
                return "http://www.keepmoney.org/download/example/csv.rar";
            }
        }

        public List<EntryField> ImportFile(string file)
        {
            List<EntryField> fields = new List<EntryField>();
           
            return fields;
        }

        public void ExportFile(List<EntryField> fields, string file)
        {

            //StreamWriter writer = new StreamWriter(textBoxPath.Text, false, Encoding.Default);
            //StringBuilder sb = new StringBuilder();//头部
            //switch (Program.AppConfig.MainForm.UItype)
            //{
            //    case UiType.Gtd:
            //        //writer.WriteLine(Program.Translation.ApplyTo("开始日期,结束日期,任务,优先级,备注,进度"));

            //        //foreach (GtdTask task in gtdView.Tasks)
            //        //{
            //        //    sb.Append(task.StartTime.ToString(configApp.DateFormat) + ",");
            //        //    sb.Append(task.EndTime.ToString(configApp.DateFormat) + ",");
            //        //    sb.Append(task.Title + ",");
            //        //    sb.Append(task.Level + ",");
            //        //    sb.Append(task.Note + ",");
            //        //    sb.Append(task.Finish ? Program.Translation.ApplyTo("完成") : Program.Translation.ApplyTo("未完成"));

            //        //    writer.WriteLine(sb.ToString());
            //        //    sb.Remove(0, sb.Length);
            //        //}
            //        break;

            //    case UiType.Money:
            //        foreach (OLVColumn column in listViewEntry.Columns)
            //            sb.Append(column.Text + ",");

            //        sb.Remove(sb.Length - 1, 1);
            //        writer.WriteLine(sb.ToString());
            //        sb.Remove(0, sb.Length);
            //        //内容
            //        foreach (OLVListItem item in listViewEntry.Items)
            //        {
            //            foreach (OLVListSubItem sub in item.SubItems)
            //                sb.Append(sub.Text + ",");

            //            sb.Remove(sb.Length - 1, 1);
            //            writer.WriteLine(sb.ToString());
            //            sb.Remove(0, sb.Length);
            //        }
            //        break;
            //}

            //writer.Flush();
            //writer.Dispose();
        }
    }
}
